home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / libq / IIcvar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-10  |  1.0 KB  |  66 lines

  1. # include    <ingres.h>
  2. # include    <symbol.h>
  3. # include    "IIglobals.h"
  4. # include    <sccs.h>
  5.  
  6. SCCSID(@(#)IIcvar.c    8.2    2/10/86)
  7.  
  8.  
  9. /*
  10. **    IIcvar -- write C variable values to parser
  11. **
  12. **
  13. **        IIcvar is used to write the contents
  14. **        of a C-variable to the quel parser.
  15. **
  16. **        Floats are converted to doubles first.
  17. **
  18. */
  19.  
  20. IIcvar(obj, type, len)
  21. char    *obj;
  22. int    type;
  23. int    len;
  24. {
  25.     register int        length;
  26.     register ANYTYPE    *addr;
  27.     char            t;
  28.     double            d;
  29.  
  30.     t = type;    /* copy type of symbol */
  31.     length = len;    /* and its length */
  32.     addr = (ANYTYPE *) obj;    /* and a pointer to it */
  33.  
  34.     switch (t)
  35.     {
  36.  
  37.       case opFLOAT:
  38.         /* convert from f4 to f8 */
  39.         d = addr->f4type;
  40.         addr = (ANYTYPE *) &d;
  41.         length = sizeof d;
  42.         t = opDOUBLE;
  43.         break;
  44.  
  45.       case opSTRING:
  46.         length = IIlength(addr) + 1;    /* length includes null byte at end */
  47.  
  48.       case opSHORT:
  49.       case opLONG:
  50.       case opDOUBLE:
  51.         break;
  52.  
  53.       default:
  54.         IIsyserr("IIcvar:bad type %d", t);
  55.     }
  56.  
  57.  
  58. #    ifdef xETR1
  59.     if (IIdebug)
  60.         printf("IIcvar:type %d, length %d\n", t, length);
  61. #    endif
  62.  
  63.     IIpb_put(&t, 1, &IIpb);
  64.     IIpb_put(addr, length, &IIpb);
  65. }
  66.